//
// Created by Semir on 2020/3/27.
//

#include <iostream>
#include <deque>

using namespace std;

const int MAX_LEN = 30;

int n;
int matrix[MAX_LEN][MAX_LEN] = {0};
int dirX[4] = {0, -1, 0, 1};
int dirY[4] = {1, 0, -1, 0};

void bfsMark() {
    deque<int> queueX;
    deque<int> queueY;
    queueX.push_back(0);
    queueY.push_back(0);
    while (!queueX.empty() && !queueY.empty()) {
        int x = queueX.front();
        int y = queueY.front();
        queueX.pop_front();
        queueY.pop_front();
        for (int i = 0; i < 4; i++) {
            int dx = x + dirX[i];
            int dy = y + dirY[i];
            if (dx >= 0 && dx <= n + 1 && dy >= 0 && dy <= n + 1 && matrix[dx][dy] == 0) {
                matrix[dx][dy] = 2;
                queueX.push_back(dx);
                queueY.push_back(dy);
            }
        }
    }
}

void smear() {
    for (int i = 1; i <= n; i++) {
        for (int j = 1; j <= n; j++) {
            matrix[i][j] = 2 - matrix[i][j];
        }
    }
}

int main() {
    cin >> n;
    for (int i = 1; i <= n; i++) {
        for (int j = 1; j <= n; j++) {
            cin >> matrix[i][j];
        }
    }
    bfsMark();
    smear();
    for (int i = 1; i <= n; i++) {
        for (int j = 1; j <= n; j++) {
            cout << matrix[i][j] << " ";
        }
        cout << endl;
    }
    return 0;
}
